<%@include file="connection.jsp" %>

<%
    String op=request.getParameter("op");
    
    if(op.equals("add")){
    String company=request.getParameter("com_name");
    String ticker = request.getParameter("ticker");
    
    st=con.createStatement();
    int a=st.executeUpdate("insert into company values (NULL,'"+company+"','"+ticker+"')");
    response.sendRedirect("companies.jsp");
    }
    
    if(op.equals("delete")){
        st=con.createStatement();
        String id=request.getParameter("val");
        //out.print(id);
        int a=st.executeUpdate("delete from company where com_id='"+id+"'");
        response.sendRedirect("companies.jsp");
    }
    
    if(op.equals("edit")){
        String id=request.getParameter("hid");
        String nm=request.getParameter("com_name");
        String ticker=request.getParameter("ticker");
        out.print(id);
        st=con.createStatement();
        int i=st.executeUpdate("update company set com_nm='"+nm+"',ticker='"+ticker+"' where com_id='"+id+"'");
        response.sendRedirect("companies.jsp");
    }
%>